<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="btn">点击发送消息</button>
  <script>
    // 1.创建一个广播频道
    // 2.监听频道的消息
    // 3.发送消息
    const bc =  new BroadcastChannel('channelName');
    btn.addEventListener('click', () => {
      bc.postMessage('你好，我是a.html');
    })
    bc.onmessage = (e) => {
      console.log(e);
    }
  </script>

</body>
</html>